#include "Register.h"

void TC::Request::Register::registerWithUsername(const QString &username, const QString &password)
{
    throw std::logic_error("" __FILE__ ", TC::Request::Register::registerWithUsername(username, password) is not implemented.");
//     if (status() == Status::Communicating)
//         return;
//     AbstractRemoteProcedure::get("user/registerWithUsername",
//     {
//         { "username", username },
//         { "password", password }
//     });
}

void TC::Request::Register::registerWithEmail(const QString &email, const QString &password)
{
    throw std::logic_error("" __FILE__ ", TC::Request::Register::registerWithEmail(email, password) is not implemented.");
//     if (status() == Status::Communicating)
//         return;
//     AbstractRemoteProcedure::get("user/registerWithEmail",
//     {
//         { "email", email },
//         { "password", password }
//     });
}

void TC::Request::Register::registerWithPhone(const QString &phone, const QString &password)
{
    if (status() == Status::Communicating)
        return;
    AbstractRemoteProcedure::get("user/registerWithPhone",
    {
        { "phone", phone },
        { "password", password }
    });
}

void TC::Request::Register::onDataReady(QDataStream &stream)
{
    bool result;
    stream >> result;
    if (result)
        setOk();
    else
        setFailed();
}